//
//  ArrayDataSourceTest.m
//  CastleryTests
//
//  Created by xie weizhi on 8/8/17.
//  Copyright © 2017 xie weizhi. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "ArrayDataSource.h"

@interface ArrayDataSourceTest : XCTestCase

@end

@implementation ArrayDataSourceTest

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testDataSource {
    ArrayDataSource *dataSource = [[ArrayDataSource alloc] initWithItems:nil];
    XCTAssertNil(dataSource.items);
    
    dataSource = [[ArrayDataSource alloc] initWithItems:@[@"1", @"2", @"3"]];
    XCTAssertEqual(3, dataSource.items.count);
    
    [dataSource appendItems:@[@"4", @"5"]];
    XCTAssertEqual(5, dataSource.items.count);
    
    
    NSString *item = @"1";
    id firstItem = [dataSource itemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    XCTAssert([item isEqualToString:firstItem]);
}


@end
